package com.henghe.frame.core.util;

import lombok.extern.slf4j.Slf4j;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * Description:
 * Author: LiuWenQing
 * Datetime: 2023/3/14 10:14
 */
@Slf4j
public class ExceptionUtil {

    private static final StringWriter sw = new StringWriter();
    private static final PrintWriter pw = new PrintWriter(sw, true);

    /**
     * 打印Exception详细信息
     */
    public static void printStackTrace(Exception e) {
        e.printStackTrace(pw);
        pw.flush();
        sw.flush();
        log.error(sw.toString());
    }
}
